<template>
    <div class="invest-wrap">
        <ul v-if="bids && bids.length">
            <li v-for="(item, index) in bids" class="invest-wrap-li" :key="index">
                <nuxt-link :to=" '/cfmatchlist/detail/' + item.bidRecordId ">
                    <div class="invest-wrap-div">
                        <p class="product-title matchlist-title"><span>{{item.bidTitle}}</span><span class="tagstyle" v-if="yjqTags(item.aheadOfTimeSettle, item.tags)">{{yjqTags(item.aheadOfTimeSettle, item.tags)}}</span></p>
                        <ul class="invest-wrap-div-ul clearfix">
                            <li class="invest-wrap-div-li left">
                                <p class="cont">{{formatMoney(item.reservedAmt)}}</p>
                                <p class="detail">匹配金额</p>
                            </li>
                            <li class="invest-wrap-div-li middle">
                                <p class="cont">{{(item.status === 'YJQ' || item.status === 'YDF') ? formatMoney(item.expectedProfit) : formatMoney(item.expectedProfit)}}</p>
                                <p class="detail">{{(item.status === 'YJQ' || item.status === 'YDF') ? '已赚收益' : '参考回报'}}</p>
                            </li>
                            <li class="invest-wrap-div-li right">
                                <p class="cont">{{(item.status === 'YJQ' || item.status === 'YDF') ? item.profitDate : item.maturityOfNextTerm}}</p>
                                <p class="detail">{{(item.status === 'YJQ' || item.status === 'YDF') ? '收益到期日' : '下期到期日'}}</p>
                            </li>
                        </ul>
                        <div class="huikuan-detail" v-if="item.status === 'HKZ'">
                            <div class="cont clearfix">
                                <p class="left">下期回款金额 <span class="money">{{formatMoney(item.repaymentOfNextTerm)}}</span></p>
                                <p class="right">所在期数 <span class="money">{{item.curRepayTerm + '/' + item.totalRepayTerm}}</span></p>
                            </div>
                        </div>
                    </div>
                </nuxt-link>
            </li>
        </ul>
        <div class="no-records" v-if="!bids || bids.length === 0">
            <img src="~/assets/img/no-records.png" class="detail-img" />
            <p class="detail">暂无匹配记录</p>
        </div>
    </div>
</template>
<script>
  import formatMoney from '~/helper/formatMoney'
  import conv from '~/helper/conv'
  export default {
    name: 'cfmatchlist',
    props: {
      bids: {
        type: Array,
        default: () => []
      }
    },
    data () {
      return {}
    },
    methods: {
      formatMoney (money) {
        if (money) {
          return formatMoney.formatMoney(money)
        }
        return money
      },
      toDateStr (date) {
        if (date) {
          return conv.toDateStr(date)
        }
        return date
      },
      period (totle, remain) {
        const current = totle - remain + 1
        return (current + '/' + totle)
      },
      linkmatch (investType, investRecordId, orderId) {
        if (investType === '1') { // 优易计划是1  网贷是0  债转是2？？债转跳什么详情
          return '/cfmatchlist/' + orderId
        } else {
          return '/bid/' + investRecordId
        }
      },
      yjqTags (aheadOfTimeSettle, tags) {
        if (aheadOfTimeSettle === '1') {
          return '提前结清'
        } else {
          return tags
        }
      }
    }
  }
</script>
<style lang='sass' src='~/assets/sass/invest-list.sass'></style>